package com.xique.door.api.factory;

import com.xique.common.core.domain.R;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.door.api.RemoteXylAlarmService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 * 
 * @author xique
 */
@Component
public class RemoteXylAlarmFallbackFactory implements FallbackFactory<RemoteXylAlarmService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteXylAlarmFallbackFactory.class);

    @Override
    public RemoteXylAlarmService create(Throwable throwable)
    {
        log.error("门禁服务调用失败:{}", throwable.getMessage());
        return new RemoteXylAlarmService()
        {
            @Override
            public AjaxResult alarmStatistics()
            {
                return AjaxResult.error("西洋楼告警统计出现异常:" + throwable.getMessage());
            }

        };

    }
}
